import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

import Layout from '../views/layouts/layout.vue';// 布局组件
const Login = () => import('../views/auth/index.vue');// 登录
const Main = () => import('../views/index/index.vue');
//内容管理
const Article = () => import('../views/article/index.vue');//新闻管理1
const ArticleUpdate = () => import('../views/article/article_update.vue');//编辑新闻1
const Share = () => import('../views/article/share.vue');//分享管理1
const ShareUpdate = () => import('../views/article/share_update.vue');//编辑分享1
const Case = () => import('../views/article/case.vue');//案列管理1
const CaseUpdate = () => import('../views/article/case_update.vue');//编辑案列1
//系统管理
const Config = () => import('../views/system/config.vue');// 系统配置1
const Adsense = () => import('../views/system/adsense.vue');// 轮播管理1
const Partner = () => import('../views/system/partner.vue');// 合作商家1
const Ecology = () => import('../views/system/ecology.vue');// 生态伙伴1
const Erp = () => import('../views/system/erp.vue');// 胜途ERP1
const Deputy = () => import('../views/system/deputy.vue');// 成功案例1
const Course = () => import('../views/system/course.vue');// 发展历程1
const Manager = () => import('../views/system/manager.vue');//管理人员1
const Channel = () => import('../views/system/channel.vue');//网站导航1
const Link = () => import('../views/system/link.vue');//友情链接1
const Honor = () => import('../views/system/honor.vue');// 富润荣誉1
const Seo = () => import('../views/system/seo.vue');//seo1
const Category = () => import('../views/system/category.vue');//分享类目1
export const constantRouterMap = [
    {path: '/login', name: 'Login', component: Login, meta: {title: '登录', login: true}},
    {
        path: '/', component: Layout, redirect: '/main',
        children: [
            {path: '/main', name: 'Main', component: Main, meta: {title: '首页', show: true, 'icon': 'fa fa-home'}},
            // {path: '/404', name: 'Error404', component: Error404, meta: {title: '404', show: false}},
        ],
    },
];

const router = new VueRouter({
    mode: 'history',
    base: '/admin',
    routes: constantRouterMap
})

export default router;

//异步挂载的路由
//动态需要根据权限加载的路由表
//access：权限ID，show：菜单是否展示，title:页面title,icon:菜单图标
export const asyncRouterMap = [
    {
        path: '/config',
        component: Layout,
        meta: {title: '系统管理', 'icon': 'fa fa-cog'},
        children: [
            {path: '/config', name: 'Config', component: Config, meta: {title: '系统设置', show: true}},
            {path: '/manager', name: 'Manager', component: Manager, meta: {title: '管理人员', show: true}},
            {path: '/category', name: 'Category', component: Category, meta: {title: '类目管理', show: true}},
        ],
    },
    {
        path: '/article',
        component: Layout,
        meta: {title: '信息管理', 'icon': 'fa fa-file-text'},
        children: [
            {path: '/article', name: 'Article', component: Article, meta: {title: '新闻中心', show: true}},
            {path: '/article/update', name: 'ArticleUpdate', component: ArticleUpdate, meta: {title: '编辑新闻', show: false}},
            {path: '/share', name: 'Share', component: Share, meta: {title: '分享管理', show: true}},
            {path: '/share/update', name: 'ShareUpdate', component: ShareUpdate, meta: {title: '编辑分享', show: false}},
            {path: '/case', name: 'Case', component: Case, meta: {title: '客户案例', show: true}},
            {path: '/case/update', name: 'CaseUpdate', component: CaseUpdate, meta: {title: '编辑案例', show: false}},
        ],
    },
    {
        path: '/channel',
        component: Layout,
        meta: {title: '链接管理', 'icon': 'fa fa-link'},
        children: [
            {path: '/channel', name: 'Channel', component: Channel, meta: {title: '网站导航', show: true}},
            {path: '/link', name: 'Link', component: Link, meta: {title: '友情链接', show: true}},
            {path: '/adsense', name: 'Adsense', component: Adsense, meta: {title: '轮播管理', show: true}},
        ],
    },
    {
        path: '/partner',
        component: Layout,
        meta: {title: '合作管理', 'icon': 'fa fa-handshake-o'},
        children: [
            {path: '/partner', name: 'Partner', component: Partner, meta: {title: '合作伙伴', show: true}},
            {path: '/ecology', name: 'Ecology', component: Ecology, meta: {title: '生态伙伴', show: true}},
            {path: '/erp', name: 'Erp', component: Erp, meta: {title: '胜途ERP', show: true}},
            {path: '/deputy', name: 'Deputy', component: Deputy, meta: {title: '成功案例', show: true}},
        ],
    },
    {
        path: '/config',
        component: Layout,
        meta: {title: '其他管理', 'icon': 'fa fa-life-buoy'},
        children: [
            {path: '/honor', name: 'Honor', component: Honor, meta: {title: '富润荣誉', show: true}},
            {path: '/seo', name: 'Seo', component: Seo, meta: {title: 'SEO设置', show: true}},
            {path: '/course', name: 'Course', component: Course, meta: {title: '发展历程', show: true}},
        ],
    },
    // {path: '*', redirect: '/error/404', name: '404', meta: {show: false},}
];
